//
//  JSLWarnRepmentController.m
//  JingleSpeedLoan
//
//  Created by 宋志彬 on 2018/8/5.
//  Copyright © 2018年 宋质彬. All rights reserved.
//

#import "JSLWarnRepmentController.h"
#import "JSLWarnRepmentCell.h"
@interface JSLWarnRepmentController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic , strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *arrDataSource;
@property (nonatomic , strong) UIView *footerView;
@end

@implementation JSLWarnRepmentController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"账单提醒";
    [self baseConfig:PageGobackTypePop];
    [self tableView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    NSMutableArray *arr =  [CacheManager getObject:@"LOAN_BILL_DATST"];
    
    self.arrDataSource = [NSMutableArray arrayWithArray:arr];
    
    if (self.arrDataSource.count == 0) {
        self.tableView.tableFooterView = self.footerView;
    }else {
        self.tableView.tableFooterView = nil;
    }
}
- (UIView *)footerView {
    
    if (_footerView == nil) {
        
        _footerView = [JSLKitFactory jsl_viewWithFrame:CGRectMake(0, 0, self.view.width, self.view.height) backgroundColor:BACKGROUND_COLOR superView:nil];
        
        
        UIImageView *imageView = [JSLKitFactory jsl_imageViewWithFrame:CGRectMake(0, 75*AutoSizeScaleYY, 126*AutoSizeScaleXX, 126*AutoSizeScaleXX) imageName:@"no-info" superView:_footerView];
        imageView.centerX = _footerView.centerX;
        
        CGSize size = [@"暂无数据，快去记一笔吧" sizeWithAttributes:@{NSFontAttributeName : REGULAR_FONT(16)}];
        [JSLKitFactory jsl_labelWithFrame:CGRectMake(0, imageView.bottom +13*AutoSizeScaleYY, _footerView.width, size.height) text:@"亲，暂无数据，快去记一笔吧···" font:REGULAR_FONT(16) textColor:[@"#888888" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:_footerView];
        
        
        //        _footerView.backgroundColor = [UIColor redColor];
        
        
    }
    
    
    return _footerView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.arrDataSource.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    JSLWarnRepmentCell *cell = [JSLWarnRepmentCell cellWithTableView:tableView];
    cell.info = self.arrDataSource[indexPath.section];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [JSLKitFactory jsl_viewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10*AutoSizeScaleYY) backgroundColor:BACKGROUND_COLOR superView:nil];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10 *AutoSizeScaleYY;
}

#pragma mark - get
- (UITableView *)tableView{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-64 -49 ) style:UITableViewStylePlain];
        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        _tableView.scrollEnabled = YES;
        _tableView.rowHeight = 86 *AutoSizeScaleYY;
        _tableView.backgroundColor = BACKGROUND_COLOR;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        [self.view addSubview:_tableView];
        
        _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
        
        //        _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(getMoreData)];
        
        _tableView.tableHeaderView = [JSLKitFactory jsl_viewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10*AutoSizeScaleYY) backgroundColor:BACKGROUND_COLOR superView:nil];
        
    }
    
    return _tableView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
